package com.LC.DAO;

import com.LC.Entity.Permission;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PermissionDAO {
    
    //查找所有权限，封装成集合返回
    @Select("select * from t_permission")
    public List<Permission> permissionList();

    @Select("<script>"+
    "select * from t_permission" +
    "<if test = 'value != null and value.length > 0'>" +
    "where keyword = #{value} or name = #{value}"+
    "</if>" +
    "</script>")
    public Page<Permission> findPage(String queryString);
    
    @Insert("insert into t_permission values(null,#{name},#{keyword},#{description})")
    public void addPermission(Permission permission);
    
    @Delete("delete from t_permission where id = #{id}")
    public void deletePermission(int id);
    
    @Select("select * from t_permission where id = #{id}")
    public Permission dataById(int id);
    
    @Update("update t_permission set name = #{name},keyword = #{keyword},description = #{description} where id = #{id}")
    public void updatePermission(Permission permission);
}
